home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Essential Home & Business Collection
/
The Essential Home & Business Collection.iso
/
27
/
3
/
5
/
HP22D5.ZIP
/
EXTERN
/
FIXENV.ASM
< prev
next >
Wrap
Assembly Source File
|
1991-04-16
|
2KB
|
93 lines
; ---------------------------------------------------------------------------
; FIXENV.ASM
;
; This program sets HyperPAD's environment to the original environment used
; by COMMAND.COM. Also, the environment that HyperPAD passes to other programs
; when they are run is the actual environment of COMMAND.COM.
;
; It performs the following steps:
;
; 1. get the address of the first memory block
; 2. it assumes the second memory block is COMMAND.COM. It finds the
; next memory block owned by this memory block
; 3. this memory block is inserted into the HyperPAD shared data
; area as the new environment
; 4. the size of the memory block is calculated and inserted into the
; appropriate field in the shared data area
;
; ---------------------------------------------------------------------------
DOSSEG
.MODEL LARGE
include extern.inc
.DATA
FixEnvName db 'STARTUP',0
Pool PoolStruct <FixEnvName,FixEnv,,HANDLER>
PoolStruct <> ;END
.CODE
WhenLoaded:
WhenUnLoaded: retf
EXTRN GetSharedArea:FAR
FixEnv proc far
push es
push si
push di
mov ah,52h ;undocumented DOS interrupt
int 21h
dec bx ;ES:[BX-2] = first memory block
dec bx
mov si,3 ;memory block offset of size
mov di,1 ;memory block offset of owner
mov ax,es:[bx] ;AX = seg of first memory block
mov es,ax
mov bx,es:[si] ;BX = size of first memory block
inc bx
add ax,bx ;AX = seg of second memory block
mov es,ax
mov dx,es:[di] ;DX = owner of second mem block (COMMAND.COM)
loop1:
mov bx,es:[si] ;BX = size of block
mov cx,bx ;CX = block size (save for later)
inc bx
add ax,bx ;AX = segment of next block
mov es,ax
cmp dx,es:[di] ;check owner
jnz loop1 ;not this block ... find next one
inc ax
mov si,ax ;SI = segment first COMMAND.COM environment
mov di,cx ;DI = size of block
call GetSharedArea ;DX:AX far pointer to shared data area
mov es,dx
mov bx,ax ;ES:BX = pointer to shared data area
mov es:[bx+618],si ;EnvSeg = segment of COMMAND.COM's environment
mov cl,4
shl di,cl ;convert paragraphs to bytes
mov es:[bx+624],di ;EnvSegSz = size fo environment block
mov ax,PASS ;pass the startup message on
pop di
pop si
pop es
ret
FixEnv endp
END